package TwentyOne.Array;

class ArraySort {

    public static void sort(int data[]) {
        // int data[] = new int[]{8, 9, 0, 2, 3, 5, 10, 7, 6, 1};
        for (int x = 0; x < data.length; x++) {
            for (int i = 0; i < data.length - x - 1; i++) {
                if (data[i] > data[i + 1]) {
                    int temp = data[i];
                    data[i] = data[i + 1];
                    data[i + 1] = temp;
                }
            }
            printArray(data);
        }
    }

    public static void printArray(int temp[]) {
        for (int x = 0; x < temp.length; x++) {
            System.out.print(temp[x] + "、");
        }
        System.out.println();
    }
}

public class a8_ArraySort {

    public static void main(String[] args) {
        int data[] = new int[]{8, 9, 0, 2, 3, 5, 10, 7, 6, 1};
        ArraySort.sort(data);    // 排序
        ArraySort.printArray(data);
    }
}
